'use strict';

const mongoose = require('mongoose'),
    complaintsModel = mongoose.model('complaints');

module.exports = {
    insertOne: insertOne,
    updateStatus : updateStatus,
    gets: gets
}

function insertOne(complaints, callback) {
    console.log(complaints)
    complaintsModel.create(complaints,function(error, data){
        callback(null,data);
    });
}

function updateStatus(complaints, callback){
    complaintsModel.updateOne({'_id':complaints._id}, complaints, function(error, data){
        callback(null,data);
    });
}

function gets(callback){
    complaintsModel.find({},function(error, data){
        callback(null,data);
    });
}